/*
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-02-01 20:53:06
 * @Description  : 一些登录相关的校验规则
 */
export const userSchema = {
  nickname: [
    {
      required: true,
      message: '请输入昵称',
      trigger: ['blur']
    },
    {
      min: 2,
      max: 50,
      trigger: ['blur'],
      message: '长度在2-50位'
    }
  ],

  username: [
    {
      required: true,
      message: '请输入用户名',
      trigger: ['blur']
    },
    {
      min: 5,
      max: 16,
      trigger: ['blur'],
      message: '长度在5-16位'
    },
    {
      pattern: /^[a-zA-Z0-9]{5,16}$/,
      message: '请输入正确格式的用户名',
      trigger: ['blur']
    }
  ],
  password: [
    {
      required: true,
      message: '请输入密码',
      trigger: ['blur']
    },
    {
      min: 5,
      max: 20,
      trigger: ['blur'],
      message: '长度在5-20位'
    },
    {
      pattern: /^[a-zA-Z0-9]{5,20}$/,
      message: '请输入正确格式的密码',
      trigger: ['blur']
    }
  ],
  email: [
    {
      required: true,
      message: '请输入邮箱',
      trigger: ['blur']
    },
    {
      validator(rule: any, value: string) {
        const regex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$/
        return regex.test(value)
      },
      trigger: ['blur'],
      message: '请输入正确的邮箱格式'
    }
  ],
  emailCode: [
    {
      required: true,
      message: '请输入验证码',
      trigger: ['blur']
    },
    {
      length: 4,
      trigger: ['blur'],
      message: '长度为4位'
    }
  ]
}
